const Koa = require('koa')
const compose = require('koa-compose')
const app = new Koa()

// 中间件
const logger = (ctx,next) => {
    console.log(`${ctx.request.url}-${ctx.request.method}-${Date.now()}`);
    next()
}

const main = (ctx) => {
ctx.response.body = 'Hello world'
}


// app.use(logger)
// app.use(main)
const middleWares = compose([logger,main])
app.use(middleWares)
app.listen(3000,() => {
    console.log('服务已启动');
})